// pages/waiting/waiting.js
let timer = null

Page({

  /**
   * 页面的初始数据
   */
  data: {
    isEnter:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getmsgStorage();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    timer = setTimeout(() => {
      this.skip()
    }, 3000)
  },

  //获取是否登录的storage
  getmsgStorage() {
    let { isEnter } = this.data;
    //获取storage
    isEnter = wx.getStorageSync('dataMsg')
    if (isEnter) {
      this.setData({ isEnter })
    }
  },


  /**
   * @desc 跳过
   */
  skip(){
    clearTimeout(timer)
    timer = null
    let { isEnter } = this.data;
    if (isEnter) {
      wx.navigateTo({
        url: '/pages/index/index',
      })
    } else {
      wx.navigateTo({
        url: '/pages/login/login',
      })
    }
  },
})